﻿$(document).ready(function() {
    UpdateManagementControls();
});

function UpdateManagementControls() {
    if($(".unit-save").length>0) {
        $(".unit-save").click(function() {
            var buttonId = $(this).attr("id");
            var commonKey = buttonId.replace("UnitSave", "");
            var siteId = commonKey.substring(0, commonKey.indexOf("_"));
            var unitId = commonKey.substring(commonKey.indexOf("_") + 1);
            var usId = "UnitStatus" + commonKey;
            var us = $("#" + usId);
            var unitStatus = us.val();
            var unitBedType = $("#UnitBedType" + commonKey).val() == null ? "" : $("#UnitBedType" + commonKey).val();
            var url = "/Management/SaveUnit/?siteId=" + siteId + "&unitId=" + unitId + "&BedStatus=" + unitStatus + "&BedType=" + unitBedType;
            SendRequest(url, { }, "UnitDiv" + commonKey);
        });
    }
}